<?php
	require_once 'init.php';
	$title = 'Yiduo - 管理员登录';
	$smarty->assign('title', $title);
	
	if (isset($_POST['adminname']) && $_POST['adminname'] != '') {
	$user = $adminDB->executeSQL("select id,fdName from ".$util->userdbName().".tbOperator where fdLogin='".$_POST['adminname']."' and fdPassword='".md5(trim($_POST['password']))."' ", $connID);
    if ($user) {
        if (isset($_SESSION['adminname'])) {
            unset($_SESSION['adminname']);
        }
        $_SESSION['adminname'] = $user[0]['fdName'];
		$_SESSION['adminid'] = $user[0]['id'];
		$sql = $adminDB->executeSQL("insert into ".$util->userdbName().".tbAdminLog (fdOperatorID,fdAction,fdTime) values('".$user[0]['id']."', 'LOGIN' , now())", $connID);
        echo "<script>window.location.href='admin-index.php';</script>";
    } else {
        echo "<script>alert('登录失败！');</script>";
    }
}	
	$smarty->display ('admin_login.html');	
	$connDB->closeConnID();
?>